<?php 
include './functions.php';
include './Upload.class.php';

$fileUpload = new Upload();
$fileUpload->uploadFiles();
// // var_dump($_FILES);exit();
 
 

if(empty($_FILES)){
	exit('文件上传失败，可能受post限制');
}
foreach ($_FILES['files']['name'] as $key => $value) {
	# code...

if($_FILES['files']['error'][$key]>0){
	switch ($_FILES['files']['error'][$key]) {
		case '1':
			exit('文件上传失败，php.ini 中 upload_max_filesize 选项限制的值');
			break;
		case '2':
			exit('上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值');
			break;
		case '3':
			# code...
			break;
		default:
			# code...
			break;
	}
}
if($_FILES['files']['size'][$key]>100000000){
	exit('文件上传失败，不能大于1000字节');
}
if (file_exists('./disk/'.$value)) {
	exit('文件已存在');
}

$arr = explode('.', $_FILES['files']['name']);
$suffix  = end($arr);
$fileName = uniqid().'.'.$suffix;


move_uploaded_file($_FILES['files']['tmp_name'][$key], './disk/'.$value);
$data['name']=$value;
$data['size']=Fdb($_FILES['files']['size'][$key]);
$data['time']=time();
$oldData = file_get_contents('./Db/db.json');
$oldData = json_decode($oldData,true);
$oldData[]=$data;
$oldData=json_encode($oldData);
file_put_contents('./Db/db.json', $oldData);

}


header('Location:./index.php');

 ?>